//package com.bto.leasetest.controller;
//
//import cn.hutool.http.HttpRequest;
//import com.alibaba.fastjson2.JSON;
//import com.alibaba.fastjson2.JSONArray;
//import com.alibaba.fastjson2.JSONObject;
//import com.alibaba.fastjson2.JSONWriter;
//import com.alibaba.nacos.api.remote.request.Request;
//import com.bto.leasetest.common.LeaseStateEnum;
//import com.bto.leasetest.dao.LeaseReviewConfigService;
//import com.bto.leasetest.dao.LeaseReviewTestService;
//import com.bto.leasetest.entity.LeaseReviewConfig;
//import com.bto.leasetest.entity.LeaseReviewTest;
//import com.bto.leasetest.request.*;
//import com.bto.leasetest.response.Cashflow;
//import com.bto.leasetest.response.Contract;
//import com.bto.leasetest.response.LeaseTokenRes;
//import com.bto.leasetest.response.ResponseBase;
//import com.bto.leasetest.response.YsxxResultRes;
//import com.bto.leasetest.service.LeaseService;
//import com.bto.leasetest.utils.DateUtils;
//import com.bto.leasetest.utils.JsonRequestHelper;
//import com.bto.leasetest.utils.LogUtils;
//import com.bto.leasetest.utils.NullUtils;
//import com.bto.leasetest.utils.StringUtils;
//import com.mybatisflex.core.query.QueryWrapper;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.cloud.context.config.annotation.RefreshScope;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.PostConstruct;
//import javax.servlet.FilterChain;
//import javax.servlet.ServletRequest;
//import javax.servlet.ServletResponse;
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//import java.util.*;
//
//import static com.bto.leasetest.entity.table.LeaseReviewTestTableDef.LEASE_REVIEW_TEST;
//
//
//@RestController
//@Slf4j
//@RefreshScope
//public class LeaseTestController {
//
//    @Value("${order.enable}")
//    public boolean enable;
//    @Value("${lease.TENANT-url}")
//    private String TENANT;
//    @Value("${lease.SELLER-url}")
//    private String SELLER;
//    @Value("${lease.FACTORY-url}")
//    private String FACTORY;
//    @Value("${lease.config-id}")
//    private Integer leaseConfigId;
//
//    @Autowired
//    private LeaseReviewTestService leaseReviewTestService;
//    @Autowired
//    private LeaseService leaseService;
//    @Autowired
//    private LeaseReviewConfigService leaseReviewConfigService;
//
//
//
//    @PostConstruct
//    public LeaseReviewConfig getLeaseReviewConfig() {
//        if (enable) {
//            LeaseReviewConfig leaseReviewConfig = leaseReviewConfigService.getById(leaseConfigId);
//            if (null == leaseReviewConfig) {
//                throw new RuntimeException("数据库没有配置初始化状态");
//            }
//            return leaseReviewConfig;
//        } else {
//            return null;
//        }
//    }
//
//
//    /**
//     * 6-01 承租人预审 access_token=test222
//     */
//    @PostMapping("/r/api/finance/sync/project/tenant")
//    public ResponseBase pushCustomerPreApproval(
//            @RequestParam(value = "access_token") String token,
//            @RequestBody @Validated RequestBase<BpMasterBaseDto> requestBase) {
//        log.info("requestBase = " + requestBase + token);
//        BpMasterBaseDto bpMasterBaseDto = requestBase.getBody().get(0);
//        LogUtils.leaseLogger.info("========================================== Start ==========================================");
//        JSONArray jsonArray = JSONArray.of(bpMasterBaseDto);
//        LogUtils.requsetLogger.info("Request Args   : {}", JSON.toJSONString(bpMasterBaseDto, JSONWriter.Feature.PrettyFormat));
//
//        String businessKey = "";
//
//        BpMasterBaseDto.HlsBpMasterDTO hlsBpMaster = bpMasterBaseDto.getHlsBpMaster();
////        if (StringUtils.isAnyBlank(hlsBpMaster.getBpCategory(),
////                hlsBpMaster.getBpName(), hlsBpMaster.getBpClass(),
////                hlsBpMaster.getIdType(), hlsBpMaster.getIdCardNo(),
////                hlsBpMaster.getGender(), hlsBpMaster.getNationality(),
////                hlsBpMaster.getCellPhone())) {
////            LogUtils.LeaseLoggerByError(ResponseBase.fail(null, "R", "有参数有空", businessKey));
////            return ResponseBase.fail(null, "R", "有参数有空", businessKey);
////        }
//
//        businessKey = hlsBpMaster.getIdCardNo();
//        if (StringUtils.isBlank(hlsBpMaster.getIdCardNo())) {
//            businessKey = hlsBpMaster.getRegno();
//        }
//
//
////        if (null == hlsBpMaster.getAge()) {
////            LogUtils.LeaseLoggerByError(ResponseBase.fail(null, "R", "有参数有空", businessKey));
////            return ResponseBase.fail(null, "R", "有参数有空", businessKey);
////        }
//
//
//            LeaseReviewTest leaseReviewTest = new LeaseReviewTest();
//            leaseReviewTest.setIdCardNo(businessKey);
//            leaseReviewTest.setTenantStatus(LeaseStateEnum.NEW.getStateId());
//            leaseReviewTestService.save(leaseReviewTest);
//
//
////        if (enable) {
////            LeaseReviewConfig leaseReviewConfig = getLeaseReviewConfig();
////            leaseReviewTest.setTenantStatus(leaseReviewConfig.getTenantStatus());
////            leaseService.asyncExecute(leaseReviewTest);
////        }
//
//
//        return ResponseBase.ok(businessKey);
//
//
//    }
//
//    /**
//     * 6-03 进件同步
//     */
//    @PostMapping("/r/api/finance/sync/project/operating/lease")
//    public ResponseBase operating(
//            @RequestParam(value = "access_token") String token,
//            @RequestBody @Validated RequestBase<OperatingBody> requestBase) {
//        log.info("requestBase = " + requestBase);
//        LogUtils.leaseLogger.info("========================================== Start ==========================================");
//        OperatingBody operatingBody = requestBase.getBody().get(0);
//        JSONArray jsonArray = JSONArray.of(operatingBody);
//        log.info("operatingBody = " + jsonArray);
//        LogUtils.requsetLogger.info("Request Args   : {}", JSON.toJSONString(operatingBody, JSONWriter.Feature.PrettyFormat));
//
//        String idCardNo = "";
//        String businessKey = "";
//
////        if (null == operatingBody.getPrjProject()) {
////            return ResponseBase.fail(null, "R", "PrjProject为空", businessKey);
////        } else if (NullUtils.isEmpty(operatingBody.getPrjProjectLeaseItemList())) {
////            return ResponseBase.fail(null, "R", "PrjProjectLeaseItemList为空", businessKey);
////        } else if (null == operatingBody.getPrjProjectProduct()) {
////            return ResponseBase.fail(null, "R", "PrjProjectProduct为空", businessKey);
////        } else if (NullUtils.isEmpty(operatingBody.getBpMasterBaseDtoList())) {
////            return ResponseBase.fail(null, "R", "BpMasterBaseDtoList为空", businessKey);
////        } else if (NullUtils.isEmpty(operatingBody.getPrjProjectAccountList())) {
////            return ResponseBase.fail(null, "R", "PrjProjectAccountList为空", businessKey);
////        }
//
////        OperatingBody.PrjProjectDTO prjProject = operatingBody.getPrjProject();
////        if (StringUtils.isAnyBlank(prjProject.getManufacturerRegno(), prjProject.getFactoryRegno(),
////                prjProject.getSellerRegno(), prjProject.getPartnersContractNumber(), prjProject.getLeaseChannel(),
////                prjProject.getDocumentType(), prjProject.getDivision(), prjProject.getLeaseDate(), prjProject.getInsuranceFlag(),
////                prjProject.getLessorCode())) {
////            return ResponseBase.fail(null, "R", "prjProject有参数为空！", businessKey);
////        }
////
////
//        List<OperatingBody.PrjProjectLeaseItemListDTO> prjProjectLeaseItemList = operatingBody.getPrjProjectLeaseItemList();
//        for (OperatingBody.PrjProjectLeaseItemListDTO prjProjectLeaseItem : prjProjectLeaseItemList) {
//            if (StringUtils.isAnyBlank(prjProjectLeaseItem.getPartnersLeaseItemId(), prjProjectLeaseItem.getFullName(),
//                     prjProjectLeaseItem.getProductModel())) {
//                return ResponseBase.fail(null, "R", "prjProjectLeaseItemList有参数为空！", businessKey);
//            }
//            businessKey = prjProjectLeaseItem.getPartnersLeaseItemId();
//
//
//            if (NullUtils.isAnyNull(prjProjectLeaseItem.getInstalledCapacity(), prjProjectLeaseItem.getModuleQuantity())) {
//                return ResponseBase.fail(null, "R", "prjProjectLeaseItemList有参数为空！", businessKey);
//            }
//        }
////
////        OperatingBody.PrjProjectProductDTO prjProjectProduct = operatingBody.getPrjProjectProduct();
////        if (StringUtils.isBlank(prjProjectProduct.getPlanCode()) || NullUtils.isEmpty(prjProjectProduct.getProductParaList())) {
////            return ResponseBase.fail(null, "R", "prjProjectProduct有参数为空！", businessKey);
////        }
////        List<OperatingBody.PrjProjectProduct.ProductPara> productParaList = prjProjectProduct.getProductParaList();
////        for (OperatingBody.PrjProjectProduct.ProductPara productPara : productParaList) {
////            if (StringUtils.isAnyBlank(productPara.getProductParaName(), productPara.getLeaseTermFrom(), productPara.getLeaseTermTo())) {
////                return ResponseBase.fail(null, "R", "productParaList有参数为空！", businessKey);
////            }
////            if (NullUtils.isNull(productPara.getProductParaValue())) {
////                return ResponseBase.fail(null, "R", "productParaList有参数为空！", businessKey);
////            }
////        }
//
//        OperatingBody.BpMasterBaseDtoListDTO.HlsBpMasterDTO  hlsBpMaster = null;
//        List<OperatingBody.BpMasterBaseDtoListDTO> bpMasterBaseDtoList = operatingBody.getBpMasterBaseDtoList();
//        for (OperatingBody.BpMasterBaseDtoListDTO bpMasterBaseDto : bpMasterBaseDtoList) {
////            if (NullUtils.isNull(bpMasterBaseDto.getHlsBpMaster())
////                    || NullUtils.isEmpty(bpMasterBaseDto.getHlsBpMasterAddressList())
////                    || NullUtils.isEmpty(bpMasterBaseDto.getHlsBpMasterBankAccountList())) {
////                return ResponseBase.fail(null, "R", "bpMasterBaseDto有参数为空！", businessKey);
////            }
//
//            hlsBpMaster = bpMasterBaseDto.getHlsBpMaster();
////            if (StringUtils.isAnyBlank(hlsBpMaster.getBpName(), hlsBpMaster.getIdCardNo(), hlsBpMaster.getCellPhone())) {
////                return ResponseBase.fail(null, "R", "hlsBpMaster有参数为空！", businessKey);
////            }
//
//            idCardNo = hlsBpMaster.getIdCardNo();
//            if (StringUtils.isBlank(hlsBpMaster.getIdCardNo())) {
//                idCardNo = hlsBpMaster.getRegno();
//            }
//
////            List<OperatingBody.BpMasterBaseDtoListDTO.HlsBpMasterAddressListDTO> hlsBpMasterAddressList = bpMasterBaseDto.getHlsBpMasterAddressList();
////            for (OperatingBody.BpMasterBaseDtoListDTO.HlsBpMasterAddressListDTO hlsBpMasterAddress : hlsBpMasterAddressList) {
////                if (StringUtils.isAnyBlank(hlsBpMasterAddress.getAddressType(), hlsBpMasterAddress.getCountryCode(),
////                        hlsBpMasterAddress.getProvinceCode(), hlsBpMasterAddress.getCityCode(),
////                        hlsBpMasterAddress.getDistrictCode(),
////                        hlsBpMasterAddress.getAddress(), hlsBpMasterAddress.getCellPhone())) {
////                    return ResponseBase.fail(null, "R", "hlsBpMasterAddressList有参数为空！", businessKey);
////                }
////            }
//
////            List<OperatingBody.BpMasterBaseDtoListDTO.HlsBpMasterBankAccountListDTO> hlsBpMasterBankAccountList = bpMasterBaseDto.getHlsBpMasterBankAccountList();
////            for (OperatingBody.BpMasterBaseDtoListDTO.HlsBpMasterBankAccountListDTO hlsBpMasterBankAccount : hlsBpMasterBankAccountList) {
////                if (StringUtils.isAnyBlank(hlsBpMasterBankAccount.getBankAccountName(), hlsBpMasterBankAccount.getBankAccountNum(),
////                        hlsBpMasterBankAccount.getTssBankNum())) {
////                    return ResponseBase.fail(null, "R", "hlsBpMasterBankAccountList有参数为空！", businessKey);
////                }
////            }
//        }
//
////        List<OperatingBody.PrjProjectAccountListDTO> prjProjectAccountList = operatingBody.getPrjProjectAccountList();
////        for (OperatingBody.PrjProjectAccountListDTO prjProjectAccount : prjProjectAccountList) {
////            if (StringUtils.isAnyBlank(prjProjectAccount.getAccountType(), prjProjectAccount.getAccountName(),
////                    prjProjectAccount.getAccountNumber(), prjProjectAccount.getTssBankNumber())) {
////                return ResponseBase.fail(null, "R", "prjProjectAccountList有参数为空！", businessKey);
////            }
////        }
//
//        LeaseReviewTest leaseReviewTestByDb = leaseReviewTestService.getOne(
//                new QueryWrapper().where(LEASE_REVIEW_TEST.ID_CARD_NO.eq(idCardNo))
//                        .orderBy(LEASE_REVIEW_TEST.CREATE_TIME, false)
//                        .limit(1).offset(0));
//
//        leaseReviewTestByDb.setBusinessKey(businessKey);
//        leaseReviewTestByDb.setContractNumber("越经（租）第000000000-ZZD-00000001号");
//        leaseReviewTestByDb.setTenantStatus(LeaseStateEnum.AUDITED.getStateId());
//        leaseReviewTestByDb.setProjectStatus(LeaseStateEnum.NEW.getStateId());
//        leaseReviewTestByDb.setIdCardNo("");
//        leaseReviewTestByDb.setLeaseReviewId(leaseReviewTestByDb.getLeaseReviewId());
//        leaseReviewTestService.updateById(leaseReviewTestByDb, false);
//
//
//        if (enable) {
//            LeaseReviewConfig leaseReviewConfig = getLeaseReviewConfig();
//            leaseReviewTestByDb.setProjectStatus(leaseReviewConfig.getProjectStatus());
//            leaseService.asyncExecute(leaseReviewTestByDb, 5000);
//        }
//
//        if (enable) {
//            String contractTextStatus = getLeaseReviewConfig().getContractTextStatus();
//            if (StringUtils.isNotBlank(hlsBpMaster.getIdCardNo())) {
//                leaseReviewTestByDb.setContractTextStatus(contractTextStatus);
//                leaseService.asyncExecute(leaseReviewTestByDb, 10000);
//            }
//        }
//
//        Map<String, Object> map = new HashMap<>();
//        map.put("contractNumber", "越经（租）第000000000-ZZD-00000001号");
//        return ResponseBase.ok(map, "接口同步成功！", businessKey);
//    }
//
//    @PostMapping("/r/api/finance/sync/project/operating/lease/sign")
//    public ResponseBase operatingSign(
//            @RequestParam(value = "access_token") String token,
//            @RequestBody @Validated RequestBase<OperatingSignBody> requestBase) {
//        log.info("requestBase = " + requestBase);
//        OperatingSignBody operatingSignBody = requestBase.getBody().get(0);
//        JSONArray jsonArray = JSONArray.of(operatingSignBody);
//        log.info("operatingBody = " + jsonArray);
//        LogUtils.requsetLogger.info("Request Args   : {}", JSON.toJSONString(operatingSignBody, JSONWriter.Feature.PrettyFormat));
//        if (null == operatingSignBody) {
//            return ResponseBase.fail(null, "R", "operatingSignBody为空！", null);
//        }
//
//        if (NullUtils.isNull(operatingSignBody.getPrjProject())) {
//            return ResponseBase.fail(null, "R", "PrjProject为空！", null);
//        } else {
//            OperatingSignBody.PrjProject prjProject = operatingSignBody.getPrjProject();
//            if (NullUtils.isNull(prjProject.getPartnersContractNumber())) {
//                return ResponseBase.fail(null, "R", "PrjProject.PartnersContractNumber为空！", null);
//            }
//        }
//
////        if (NullUtils.isEmpty(operatingSignBody.getPrjProjectLeaseItemList())) {
////            return ResponseBase.fail(null, "R", "PrjProjectLeaseItemList为空！", null);
////        } else {
////            List<OperatingSignBody.PrjProjectLeaseItem> prjProjectLeaseItemList = operatingSignBody.getPrjProjectLeaseItemList();
////            for (OperatingSignBody.PrjProjectLeaseItem prjProjectLeaseItem : prjProjectLeaseItemList) {
////                if (StringUtils.isAnyBlank(prjProjectLeaseItem.getPartnersLeaseItemId(), prjProjectLeaseItem.getModuleProducer(),
////                        prjProjectLeaseItem.getProductModel(), prjProjectLeaseItem.getInverterNumber(),
////                        prjProjectLeaseItem.getInverterBrand(), prjProjectLeaseItem.getInverterModel(),
////                        prjProjectLeaseItem.getAddressConsistent())){
////                    return ResponseBase.fail(null, "R", "prjProjectLeaseItemList有参数为空！", null);
////                }
////                if (NullUtils.isAnyNull(prjProjectLeaseItem.getInstalledCapacity(), prjProjectLeaseItem.getModuleQuantity())) {
////                    return ResponseBase.fail(null, "R", "InstalledCapacity或者ModuleQuantity为空！", null);
////                }
////                if (NullUtils.isEmpty(prjProjectLeaseItem.getModuleList())) {
////                    return ResponseBase.fail(null, "R", "ModuleList为空！", null);
////                }
////            }
////        }
//
//        String businessKey = operatingSignBody.getPrjProject().getPartnersContractNumber();
//        if (StringUtils.isBlank(businessKey)) {
//            return ResponseBase.fail(null, "R", "partnersContractNumber为空！", null);
//        }
//        LeaseReviewTest leaseReviewTestByDb = leaseReviewTestService.getOne(
//                new QueryWrapper().where(LEASE_REVIEW_TEST.BUSINESS_KEY.eq(businessKey)));
//        if (enable) {
//            LeaseReviewConfig leaseReviewConfig = getLeaseReviewConfig();
//            if (LeaseStateEnum.APPROVED.getStateId().equals(leaseReviewConfig.getFarmerSignStatus())) {
//                leaseReviewTestByDb.setFarmerSignStatus(LeaseStateEnum.WAITING.getStateId());
//            } else {
//                leaseReviewTestByDb.setFarmerSignStatus(leaseReviewConfig.getFarmerSignStatus());
//            }
//        }
//        leaseService.asyncExecute(leaseReviewTestByDb);
//
//        return ResponseBase.ok();
//    }
//
//    @PostMapping("/r/api/finance/ol/sync/sign/update")
//    public ResponseBase operatingSignUpdate(
//            @RequestParam(value = "access_token") String token,
//            @RequestBody @Validated RequestBase<OperatingSignBody> requestBase) {
//        log.info("requestBase = " + requestBase);
//        OperatingSignBody operatingSignBody = requestBase.getBody().get(0);
//        JSONArray jsonArray = JSONArray.of(operatingSignBody);
//        log.info("operatingBody = " + jsonArray);
//        LogUtils.requsetLogger.info("Request Args   : {}", JSON.toJSONString(operatingSignBody, JSONWriter.Feature.PrettyFormat));
//        if (null == operatingSignBody) {
//            return ResponseBase.fail(null, "R", "operatingSignBody为空！", null);
//        }
//
//        if (NullUtils.isNull(operatingSignBody.getPrjProject())) {
//            return ResponseBase.fail(null, "R", "PrjProject为空！", null);
//        } else {
//            OperatingSignBody.PrjProject prjProject = operatingSignBody.getPrjProject();
//            if (StringUtils.isAnyBlank(prjProject.getPartnersContractNumber(), prjProject.getGridTiedDate())) {
//                return ResponseBase.fail(null, "R", "PrjProject.PartnersContractNumber或者GridTiedDate为空！", null);
//            }
//        }
//
//        if (NullUtils.isEmpty(operatingSignBody.getPrjProjectLeaseItemList())) {
//            return ResponseBase.fail(null, "R", "PrjProjectLeaseItemList为空！", null);
//        } else {
//            List<OperatingSignBody.PrjProjectLeaseItem> prjProjectLeaseItemList = operatingSignBody.getPrjProjectLeaseItemList();
//            for (OperatingSignBody.PrjProjectLeaseItem prjProjectLeaseItem : prjProjectLeaseItemList) {
//                if (StringUtils.isAnyBlank(prjProjectLeaseItem.getPartnersLeaseItemId(), prjProjectLeaseItem.getAddressConsistent())) {
//                    return ResponseBase.fail(null, "R", "PartnersLeaseItemId或者AddressConsistent为空！", null);
//                }
//                if ("N".equals(prjProjectLeaseItem.getAddressConsistent())) {
//                    if (StringUtils.isAnyBlank(prjProjectLeaseItem.getElectricProvinceCode(), prjProjectLeaseItem.getElectricCityCode(),
//                            prjProjectLeaseItem.getElectricAreaCode(), prjProjectLeaseItem.getElectricAddress())) {
//                        return ResponseBase.fail(null, "R", "AddressConsistent以下的参数为空！", null);
//                    }
//                }
//                if (NullUtils.isEmpty(prjProjectLeaseItem.getInsuranceList())) {
//                    return ResponseBase.fail(null, "R", "InsuranceList为空！", null);
//                } else {
//                    List<OperatingSignBody.Insurance> insuranceList = prjProjectLeaseItem.getInsuranceList();
//                    for (OperatingSignBody.Insurance insurance : insuranceList) {
//                        if (StringUtils.isAnyBlank(insurance.getInsuranceType(), insurance.getInsuranceDateFrom(),
//                                insurance.getInsuranceDateTo(), insurance.getInsuranceCompany(), insurance.getInsuranceNumber(),
//                                insurance.getFirstBeneficiary())) {
//                            return ResponseBase.fail(null, "R", "insuranceList有参数为空！", null);
//                        }
//                        if (NullUtils.isNull(insurance.getInsuranceAmount())) {
//                            return ResponseBase.fail(null, "R", "InsuranceAmount为空！", null);
//                        }
//                    }
//                }
//            }
//        }
//
//        if (NullUtils.isEmpty(operatingSignBody.getPrjProjectAccountList())) {
//            return ResponseBase.fail(null, "R", "PrjProjectAccountList为空！", null);
//        } else {
//            List<OperatingSignBody.PrjProjectAccount> prjProjectAccountList = operatingSignBody.getPrjProjectAccountList();
//            for (OperatingSignBody.PrjProjectAccount prjProjectAccount : prjProjectAccountList) {
//                if (StringUtils.isAnyBlank(prjProjectAccount.getAccountType(), prjProjectAccount.getAccountName(),
//                        prjProjectAccount.getAccountNumber())){
//                    return ResponseBase.fail(null, "R", "PrjProjectAccountList有参数空！", null);
//                }
//            }
//        }
//
//        String businessKey = operatingSignBody.getPrjProject().getPartnersContractNumber();
//        LeaseReviewTest leaseReviewTestByDb = leaseReviewTestService.getOne(
//                new QueryWrapper().where(LEASE_REVIEW_TEST.BUSINESS_KEY.eq(businessKey)));
//
//        if (enable) {
//            LeaseReviewConfig leaseReviewConfig = getLeaseReviewConfig();
//            LeaseReviewTest leaseReviewTestByDbOne = new LeaseReviewTest();
//            BeanUtils.copyProperties(leaseReviewTestByDb, leaseReviewTestByDbOne);
//            leaseReviewTestByDbOne.setFarmerSignStatus(leaseReviewConfig.getFarmerSignStatus());
//            leaseReviewTestByDb.setFarmerSignStatus(leaseReviewConfig.getFarmerSignStatus());
//            leaseService.asyncExecute(leaseReviewTestByDbOne, 15000);
//        }
//
//        if (enable) {
//            LeaseReviewConfig leaseReviewConfig = getLeaseReviewConfig();
//            LeaseReviewTest leaseReviewTestByDbTwo = new LeaseReviewTest();
//            BeanUtils.copyProperties(leaseReviewTestByDb, leaseReviewTestByDbTwo);
//            leaseReviewTestByDbTwo.setContractStatus(leaseReviewConfig.getContractStatus());
//            leaseReviewTestByDb.setContractStatus(leaseReviewConfig.getContractStatus());
//            leaseService.asyncExecute(leaseReviewTestByDbTwo, 20000);
//        }
//
//
//        return ResponseBase.ok();
//    }
//
//    @PostMapping("/r/api/finance/ol/power/sell/file")
//    public ResponseBase powerSellOlFileContractPushLease(
//            @RequestParam(value = "access_token") String token,
//            @RequestBody @Validated RequestBase<PowerSellOlFIleBody> requestBase) {
//        log.info("requestBase = " + requestBase);
//        PowerSellOlFIleBody powerSellOlFIleBody = requestBase.getBody().get(0);
//        JSONArray jsonArray = JSONArray.of(powerSellOlFIleBody);
//        log.info("operatingBody = " + jsonArray);
//        LogUtils.requsetLogger.info("Request Args   : {}", JSON.toJSONString(powerSellOlFIleBody, JSONWriter.Feature.PrettyFormat));
//
//        if (null == powerSellOlFIleBody) {
//            return ResponseBase.fail(null, "R", "powerSellOlFIleBody为空！", null);
//        }
//
//        if (NullUtils.isNull(powerSellOlFIleBody.getPrjProject())) {
//            return ResponseBase.fail(null, "R", "PrjProject为空！", null);
//        } else {
//            PowerSellOlFIleBody.PrjProject prjProject = powerSellOlFIleBody.getPrjProject();
//            if (StringUtils.isBlank(prjProject.getPartnersContractNumber())) {
//                return ResponseBase.fail(null, "R", "PartnersContractNumber为空！", null);
//            }
//        }
//
//        if (NullUtils.isEmpty(powerSellOlFIleBody.getPrjProjectLeaseItemList())) {
//            return ResponseBase.fail(null, "R", "PrjProjectLeaseItemList为空！", null);
//        } else {
//            List<PowerSellOlFIleBody.PrjProjectLeaseItem> prjProjectLeaseItemList = powerSellOlFIleBody.getPrjProjectLeaseItemList();
//            for (PowerSellOlFIleBody.PrjProjectLeaseItem prjProjectLeaseItem : prjProjectLeaseItemList) {
//                if (StringUtils.isAnyBlank(prjProjectLeaseItem.getPartnersLeaseItemId(), prjProjectLeaseItem.getProductModel(),
//                        prjProjectLeaseItem.getInverterNumber(), prjProjectLeaseItem.getAddressConsistent())) {
//                    return ResponseBase.fail(null, "R", "LeaseItemNumber为空！", null);
//                }
//
//                if ("N".equals(prjProjectLeaseItem.getAddressConsistent())) {
//                    if (StringUtils.isAnyBlank(prjProjectLeaseItem.getElectricProvinceCode(), prjProjectLeaseItem.getElectricCityCode(),
//                            prjProjectLeaseItem.getElectricAreaCode(), prjProjectLeaseItem.getElectricAddress())) {
//                        return ResponseBase.fail(null, "R", "LAddressConsistent以下有参数为空！", null);
//                    }
//                }
//            }
//        }
//
//        if (NullUtils.isNull(powerSellOlFIleBody.getFinanceProjectFileInfoDto())) {
//            return ResponseBase.fail(null, "R", "PrjProjectLeaseItemList为空！", null);
//        } else {
//            PowerSellOlFIleBody.FinanceProjectFileInfoDto financeProjectFileInfoDto = powerSellOlFIleBody.getFinanceProjectFileInfoDto();
//            if (StringUtils.isAnyBlank(financeProjectFileInfoDto.getKeyType(), financeProjectFileInfoDto.getBusinessKey())) {
//                return ResponseBase.fail(null, "R", "financeProjectFileInfoDto有参数为空！", null);
//            }
//            if (NullUtils.isNull(financeProjectFileInfoDto.getFileList())) {
//                return ResponseBase.fail(null, "R", "FileList为空！", null);
//            } else {
//                List<PowerSellOlFIleBody.FinanceProjectFileInfoDto.FileList> fileList = financeProjectFileInfoDto.getFileList();
//                for (PowerSellOlFIleBody.FinanceProjectFileInfoDto.FileList list : fileList) {
//                    if (StringUtils.isAnyBlank(list.getFileCode(), list.getFileName(), list.getFileAddress())) {
//                        return ResponseBase.fail(null, "R", "FileList有参数为空！", null);
//                    }
//                }
//            }
//        }
//
//        String businessKey = powerSellOlFIleBody.getPrjProject().getPartnersContractNumber();
//        LeaseReviewTest leaseReviewTestByDb = leaseReviewTestService.getOne(
//                new QueryWrapper().where(LEASE_REVIEW_TEST.BUSINESS_KEY.eq(businessKey)));
//        if (enable) {
//            LeaseReviewConfig leaseReviewConfig = getLeaseReviewConfig();
//            leaseReviewTestByDb.setContractPowerStatus(leaseReviewConfig.getContractPowerStatus());
//        }
//        leaseService.asyncExecute(leaseReviewTestByDb);
//
//        return ResponseBase.ok();
//    }
//
//    @PostMapping("/r/api/finance/contract/file/get")
//    public ResponseBase getContractFile(
//            @RequestParam(value = "access_token") String token,
//            @RequestBody @Validated RequestBase<FileContractBody> requestBase) {
//        log.info("requestBase = " + requestBase);
//        FileContractBody fileContractBody = requestBase.getBody().get(0);
//        JSONArray jsonArray = JSONArray.of(fileContractBody);
//        log.info("operatingBody = " + jsonArray);
//        LogUtils.requsetLogger.info("Request Args   : {}", JSON.toJSONString(fileContractBody, JSONWriter.Feature.PrettyFormat));
//
//        if (null == fileContractBody) {
//            return ResponseBase.fail(null, "R", "fileContractBody为空！", null);
//        }
//
//        List<Contract> contractList = new ArrayList<>();
//        Contract contract = new Contract();
//        List<Contract.FileMessage> fileMessageList = new ArrayList<>();
//        //  TENANT-url: http://qiniu.btowork.top/sit/order/2023-10/2310151533025062/博通屋顶租赁协议23.04.03 (8).pdf
//        Contract.FileMessage fileMessageByOne = new Contract.FileMessage();
//        fileMessageByOne.setDocumentName("博通屋顶租赁协议23.04.03.pdf");
//        fileMessageByOne.setUrl(TENANT);
//        //fileMessageByOne.setUrl("http://qiniu.btowork.top/prod/2023-12/2312201635324127/ltZnEZWiGpZeN2w7tYNZ30_h6NVN.pdf");
//        fileMessageByOne.setUsageCategory("TENANT");
//        fileMessageList.add(fileMessageByOne);
//        //  SELLER-url: http://qiniu.btowork.top/sit/order/2023-10/2310151533025062/博通_合作共建_购买合同（直租）.pdf
//        Contract.FileMessage fileMessageByTwo = new Contract.FileMessage();
//        fileMessageByTwo.setDocumentName("博通_合作共建_购买合同（直租）.pdf");
//        fileMessageByTwo.setUrl(SELLER);
//        //fileMessageByTwo.setUrl("http://qiniu.btowork.top/prod/2023-12/2312201635324127/ltZnEZWiGpZeN2w7tYNZ30_h6NVN.pdf");
//        fileMessageByTwo.setUsageCategory("SELLER");
//        fileMessageList.add(fileMessageByTwo);
//        //  FACTORY-url: http://qiniu.btowork.top/sit/order/2023-10/2310151533025062/博通-合作共建-运维确认书.pdf
//        Contract.FileMessage fileMessageByThree = new Contract.FileMessage();
//        fileMessageByThree.setDocumentName("博通-合作共建-运维确认书.pdf");
//        fileMessageByThree.setUrl(FACTORY);
//        //fileMessageByThree.setUrl("http://qiniu.btowork.top/prod/2023-12/2312201635324127/ltZnEZWiGpZeN2w7tYNZ30_h6NVN.pdf");
//        fileMessageByThree.setUsageCategory("FACTORY");
//        fileMessageList.add(fileMessageByThree);
//
//        contract.setFileMessage(fileMessageList);
//        contractList.add(contract);
//        Map<String, Object> map = new HashMap<>();
//        map.put("contract", contractList);
//
//        return ResponseBase.ok(map, "接口同步成功！", "11111");
//
//    }
//
//    @PostMapping("/r/api/finance/project/operating/lease/farm/gains")
//    public ResponseBase operatingFarmFainsQuery(
//            @RequestParam(value = "access_token") String token,
//            @RequestBody @Validated RequestBase<CashflowInfo> requestBase)  {
//        log.info("requestBase = " + requestBase);
//        CashflowInfo cashflowInfo = requestBase.getBody().get(0);
//        JSONArray jsonArray = JSONArray.of(cashflowInfo);
//        log.info("operatingBody = " + jsonArray);
//        LogUtils.requsetLogger.info("Request Args   : {}", JSON.toJSONString(cashflowInfo, JSONWriter.Feature.PrettyFormat));
//
//        if (null == cashflowInfo) {
//            return ResponseBase.fail(null, "R", "cashflowInfo为空！", null);
//        }
//        CashflowInfo.OlDocumentFarmGainsDto olDocumentFarmGainsDto = cashflowInfo.getOlDocumentFarmGainsDto();
//        if (StringUtils.isBlank(olDocumentFarmGainsDto.getSynchronizationType())) {
//            return ResponseBase.fail(null, "R", "getSynchronizationType为空！", null);
//        }
//        if ("FULL".equals(olDocumentFarmGainsDto.getSynchronizationType())) {
//            if (StringUtils.isAnyBlank(olDocumentFarmGainsDto.getDueDateFrom(), olDocumentFarmGainsDto.getDueDateTo())) {
//                return ResponseBase.fail(null, "R", "dateFrom或者dateTo为空！", null);
//            }
//            try {
//                Date dateFrom = DateUtils.parseDate(olDocumentFarmGainsDto.getDueDateFrom(),  "yyyyMMdd");
//                Date dateTo = DateUtils.parseDate(olDocumentFarmGainsDto.getDueDateTo(),  "yyyyMMdd");
//            } catch (Exception e) {
//                return ResponseBase.fail(null, "R", "dateFrom或者dateTo格式有误！", null);
//            }
//        }
//
//
//        Map<String, Object> map = new HashMap<>();
//        map.put( "type", "S");
//        map.put( "message", "接口查询成功");
//        map.put( "businessKey", "");
//        Cashflow cashflow = new Cashflow();
//        cashflow.setPartnersContractNumber(olDocumentFarmGainsDto.getPartnersContractNumber());
//        cashflow.setCfId(329128);
//        cashflow.setTimes("4");
//        cashflow.setCfItem("125");
//        cashflow.setCfDirection("OUTFLOW");
//        cashflow.setDueAmount(5550.0);
//        cashflow.setDueDate("20230805");
//        cashflow.setReceivedDate("");
//        cashflow.setReceivedAmount(0.0);
//        cashflow.setWriteOffFlag("NOT");
//        List<Cashflow> cashflowList = new ArrayList<>();
//        cashflowList.add(cashflow);
//        map.put("cashflowList", cashflowList);
//
//        return ResponseBase.ok(map, "接口查询成功！", "11111");
//
//    }
//
//    @PostMapping("/r/api/finance/ol/sync/file")
//    public ResponseBase files(
//            @RequestParam(value = "access_token") String token,
//            @RequestBody @Validated RequestBase<FileContractPushBody> requestBase) {
//        log.info("requestBase = " + requestBase);
//        FileContractPushBody fileContractPushBody = requestBase.getBody().get(0);
//        JSONArray jsonArray = JSONArray.of(fileContractPushBody);
//        log.info("fileContractPushBody = " + jsonArray);
//        LogUtils.requsetLogger.info("Request Args   : {}", JSON.toJSONString(fileContractPushBody, JSONWriter.Feature.PrettyFormat));
//        return ResponseBase.ok();
//    }
//
//    //password=Password@123&grant_type=password&client_secret=53e18ab1-67cc-475f-b54b-32c00f8b9bd6&client_id=Finance&username=gdbt001
//    @PostMapping("/oauth/token")
//    public LeaseTokenRes getLeaseToken(
//            @RequestParam(value = "client_id") String clientId,
//            @RequestParam(value = "client_secret") String clientSecret,
//            @RequestParam(value = "username") String username,
//            @RequestParam(value = "password") String password,
//            @RequestParam(value = "grant_type") String grantType
//    ) {
//        return new LeaseTokenRes().setJti("test111").setAccessToken("test222");
//    }
//
//    @PostMapping("/r/api/finance/project/tenant/status/query")
//    public ResponseBase getYsxxResultRes(
//            @RequestParam(value = "access_token") String token,
//            @RequestBody RequestBase<YsxxReq> requestBase) {
//        log.info("requestBase = " + requestBase);
//        YsxxReq ysxxReq = requestBase.getBody().get(0);
//        JSONArray jsonArray = JSONArray.of(ysxxReq);
//        log.info("fileContractPushBody = " + jsonArray);
//        LogUtils.requsetLogger.info("Request Args   : {}", JSON.toJSONString(ysxxReq, JSONWriter.Feature.PrettyFormat));
//        if (enable) {
//            LeaseReviewConfig leaseReviewConfig = leaseReviewConfigService.getById(leaseConfigId);
//            Map<String, Object> map = new HashMap<>();
//            map.put( "idCardNo", ysxxReq.getIdCardNo());
//            map.put( "type", "S");
//            map.put( "result", leaseReviewConfig.getTenantStatus());
//            map.put("reason", "成功");
//
//
//            return ResponseBase.ok(map, "接口查询成功！", ysxxReq.getIdCardNo());
//        } else {
//            LeaseReviewConfig leaseReviewConfig = leaseReviewConfigService.getById(leaseConfigId);
//            Map<String, Object> map = new HashMap<>();
//            map.put( "idCardNo", ysxxReq.getIdCardNo());
//            map.put( "type", "S");
//            map.put( "result", "REJECT");
//            map.put("reason", "瑞哥经常去");
//
//
//            return ResponseBase.ok(map, "接口查询成功！", ysxxReq.getIdCardNo());
//        }
//
//
//    }
//
//
//
//
//
//
//
//}
